package logic_settings_user

import (
	v1 "Sailor/app/Sailor-console-server/api/api_task/v1"
	"Sailor/app/Sailor-console-server/internal/dao"
	"Sailor/app/Sailor-console-server/internal/model/entity"
	"Sailor/app/Sailor-console-server/utility/utility_task"
	"context"
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
)

func (s *sTask) LogicTaskRunOne(ctx context.Context, req *v1.TaskRunOneReq) (res *v1.TaskRunOneRes, err error) {
	var tasks entity.SysTask
	err = dao.SysTask.Ctx(ctx).Where(dao.SysTask.Columns().Uuid, req.Uuid).Scan(&tasks)
	if err != nil {
		g.Log().Error(ctx, err)
		return nil, gerror.New("运行任务失败")
	}
	utility_task.Run(tasks)
	return &v1.TaskRunOneRes{}, nil
}
